unit frm_FilterPays;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, shbl_Filter, PropFilerEh, PropStorageEh, ActnList, Menus,
  StdCtrls, Buttons, ExtCtrls, Mask, DBCtrlsEh, DBGridEh, DBLookupEh, DB,
  FIBDataSet, pFIBDataSet, FIBDatabase, pFIBDatabase;

type
  TfrmFilterPays = class(TshblFilter)
    cbType1: TDBCheckBoxEh;
    cbPayDate2: TDBCheckBoxEh;
    cbAccepted4: TDBCheckBoxEh;
    cbNotes5: TDBCheckBoxEh;
    eNotes: TDBEditEh;
    cbDeleted6: TDBCheckBoxEh;
    lcbType: TDBLookupComboboxEh;
    dteBdate: TDBDateTimeEditEh;
    dteEdate: TDBDateTimeEditEh;
    Label1: TLabel;
    Label2: TLabel;
    dsTypes: TpFIBDataSet;
    dscTypes: TDataSource;
    cbName1: TDBCheckBoxEh;
    cbStreet2: TDBCheckBoxEh;
    cbHouse3: TDBCheckBoxEh;
    cbApparts4: TDBCheckBoxEh;
    eName: TDBEditEh;
    eHouse: TDBEditEh;
    eApparts: TDBEditEh;
    cbContragent10: TDBCheckBoxEh;
    eContragent: TDBLookupComboboxEh;
    dsContragents: TpFIBDataSet;
    dscContragents: TDataSource;
    trLists: TpFIBTransaction;
    ePaySource: TDBLookupComboboxEh;
    cbPaySource23: TDBCheckBoxEh;
    dsPaySource: TpFIBDataSet;
    dsPaySourceID: TFIBIntegerField;
    dsPaySourceNAME: TFIBStringField;
    dscPaySource: TDataSource;
    cbMinSumm8: TDBCheckBoxEh;
    eMinSumm: TDBNumberEditEh;
    cbMaxSumm9: TDBCheckBoxEh;
    eMaxSumm: TDBNumberEditEh;
    lcbDType: TDBLookupComboboxEh;
    cbDType: TDBCheckBoxEh;
    eStreet: TDBLookupComboboxEh;
    dsStreets: TpFIBDataSet;
    dscStreets: TDataSource;
    pDeleted: TPanel;
    cbDeleted: TRadioButton;
    RadioButton3: TRadioButton;
    Panel2: TPanel;
    cbAccepted: TRadioButton;
    RadioButton2: TRadioButton;
    procedure cbType1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure aApplyExecute(Sender: TObject);
    procedure dteBdateChange(Sender: TObject);
    procedure cbType1KeyPress(Sender: TObject; var Key: Char);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frmFilterPays: TfrmFilterPays;

implementation

uses MAIN, MAIN_DM, rst_Pays;

{$R *.dfm}

procedure TfrmFilterPays.cbType1Click(Sender: TObject);
begin
  EnableControlByTag(Self, (Sender as TWinControl), (Sender as TWinControl).Tag, (Sender as TDBCheckBoxEh).Checked);
end;

procedure TfrmFilterPays.FormCreate(Sender: TObject);
begin
  dsStreets.Open;
  dsTypes.Open;
  dsContragents.Open;
  dsPaySource.Open;
  dteEdate.Value := Now;  
  dteBdate.Value := Now;
  eMinSumm.Value := 0;
  eMaxSumm.Value := 10000;  
end;

procedure TfrmFilterPays.aApplyExecute(Sender: TObject);
begin
  Self.Close;
  (Self.Owner as TrstPays).aFilterApply;
end;

procedure TfrmFilterPays.dteBdateChange(Sender: TObject);
begin
  if VarIsNull(dteBdate.Value) or VarIsNull(dteEdate.Value) then exit;
  if VarToDateTime(dteEdate.Value) < VarToDateTime(dteBdate.Value) then
    dteEdate.Value := dteBdate.Value;
end;

procedure TfrmFilterPays.cbType1KeyPress(Sender: TObject; var Key: Char);
begin
  inherited;
  if Key = #13 then
    Self.FindNextControl((Sender as TWinControl), true, true, false).SetFocus;
end;

end.
